clear
set more off
capture log off
cd "C:\Users\52879203\Documents"
use "C:\Users\52879203\Documents\GSS2022.dta"

count // TOTAL RESPONDENTS

svyset [pweight=wtssps]


******************************CLEANED VARIABLES*********************************

******************************DEPENDENT VARIABLE********************************
tab slpprblm, m
drop if missing(slpprblm)
recode slpprblm (1=4 "Often") (2=3 "Sometimes") (3=2 "Rarely") (4=1 "Never"), gen(newslpprblm)
tab newslpprblm

*********************************INDEPENDENT VARIABLE***************************
tab confed, m
drop if missing(confed)

tab conjudge, m
drop if missing(conjudge)

tab conlegis, m
drop if missing(conlegis)

alpha confed conjudge conlegis // TESTING CRONBACH'S ALPHA RELIABILITY

gen poldistrust = confed + conjudge + conlegis
label var poldistrust "Political Distrust index"
tab poldistrust, m

*****************************CONTROL VARIABLES**********************************
tab age, m
drop if missing(age)

tab sex, m
drop if missing(sex)
recode sex (1=0 "Male") (2=1 "Female"), gen(newsex)
tab newsex, m

tab race, m
drop if missing(race)

tab childs, m
drop if missing(childs)

tab marital, m
drop if missing(marital)
recode marital (2/5=0 "Not married") (1=1 "Married"), gen(newmarital)
tab newmarital, m

tab income16, m
drop if missing(income16)

tab health, m
drop if missing(health)

tab polviews, m
drop if missing(polviews)

tab partyid, m
drop if missing(partyid)

tab educ, m
drop if missing(educ)
recode educ (0/7=1 "Less than high school") (8/11=2 "High school") (12/14=3 "Some college") (15/20=4 "Bachelor's degree or more"), gen(neweduc)
tab neweduc, m


**********************************ANALYTIC SAMPLE*******************************
keep id newslpprblm poldistrust age race newsex childs newmarital income16 health polviews partyid neweduc wtssps

count if !missing(newslpprblm, poldistrust, age, childs, race, income16, partyid, polviews, health, newsex, newmarital, neweduc) // TOTAL RESPONDENTS IN ANALYTIC SAMPLE


*****************************DESCRIPTIVE STATISTICS***************************** 
tab newslpprblm, m
tab race, m
tab newsex, m
tab newmarital, m
tab health, m
tab polviews, m
tab partyid, m
tab neweduc, m

summarize poldistrust, d
summarize childs, d
summarize income16, d
summarize age, d

************************ORDINAL LOGISTIC REGRESSION***************************** 
ologit newslpprblm c.poldistrust, or /// MODEL 1

omodel logit newslpprblm poldistrust /// TESTING PARALLEL LINE ASSUMPTIONS


ologit newslpprblm c.poldistrust age i.race i.newsex i.neweduc childs i.newmarital income16 i.health i.polviews i.partyid, or /// MODEL 2


************************MODEL FIT STATISTICS************************************
ologit newslpprblm c.poldistrust or // MODEL 1
estat ic

ologit newslpprblm c.poldistrust age i.race i.newsex i.neweduc childs i.newmarital income16 i.health i.polviews i.partyid, or // MODEL 2
estat ic

**********************************AVERAGE MARGINAL EFFECTS**********************
ologit newslpprblm c.poldistrust age i.race i.newsex i.neweduc childs i.newmarital income16 i.health i.polviews i.partyid, or
margins, dydx(poldistrust)

****************************PREDICTED PROBABILITIES*****************************
ologit newslpprblm c.poldistrust age i.race i.newsex i.neweduc childs i.newmarital income16 i.health i.polviews i.partyid, or
margins, at(poldistrust=(3(1)9)) predict(outcome(1)) post
marginsplot, recast(line) ciopts(recast(rline)) title("Predicted Pr(Sleep = Never)") ytitle("Pr(Y=Never)") xtitle("Political Distrust Index (3-9)") legend(off) name(pr_never, replace)

ologit newslpprblm c.poldistrust age i.race i.newsex i.neweduc childs i.newmarital income16 i.health i.polviews i.partyid, or
margins, at(poldistrust=(3(1)9)) predict(outcome(2)) post
marginsplot, recast(line) ciopts(recast(rline)) title("Predicted Pr(Sleep = Rarely)") ytitle("Pr(Y=Rarely)") xtitle("Political Distrust Index (3-9)") legend(off) name(pr_rarely, replace)

ologit newslpprblm c.poldistrust age i.race i.newsex i.neweduc childs i.newmarital income16 i.health i.polviews i.partyid, or
margins, at(poldistrust=(3(1)9)) predict(outcome(3)) post
marginsplot, recast(line) ciopts(recast(rline)) title("Predicted Pr(Sleep = Sometimes)") ytitle("Pr(Y=Sometimes)") xtitle("Political Distrust Index (3-9)") legend(off) name(pr_sometimes, replace)

ologit newslpprblm c.poldistrust age i.race i.newsex i.neweduc childs i.newmarital income16 i.health i.polviews i.partyid, or
margins, at(poldistrust=(3(1)9)) predict(outcome(4)) post
marginsplot, recast(line) ciopts(recast(rline)) title("Predicted Pr(Sleep = Often)") ytitle("Pr(Y=Often)") xtitle("Political Distrust Index (3-9)") legend(off) name(pr_often, replace)

translate "09152025 - Beulah Suleman - 2022 - Copy - Copy.do" "Beulah D. Suleman - 09152025.pdf", translator(txt2pdf)

















